package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCRequireStatus;
import com.shrct.businessprocess.customerservice.RCServiceContractDelegate;
import com.shrct.businessprocess.customerservice.RCServiceContractDelegateCriteria;
import com.shrct.businessprocess.organization.RCEnterprise;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class RCServiceContractDelegateCriteriaImpl extends HQLBasedPagedQueryCriteria<RCServiceContractDelegate> implements RCServiceContractDelegateCriteria {
  private String info;
  
  public String getInfo() {
    return this.info;
  }
  
  public RCServiceContractDelegateCriteria setInfo(final String info) {
    this.info = info;
    return this;			
    
  }
  
  private String projectInfo;
  
  public String getProjectInfo() {
    return this.projectInfo;
  }
  
  public RCServiceContractDelegateCriteria setProjectInfo(final String projectInfo) {
    this.projectInfo = projectInfo;
    return this;			
    
  }
  
  private String contractId;
  
  public String getContractId() {
    return this.contractId;
  }
  
  public RCServiceContractDelegateCriteria setContractId(final String contractId) {
    this.contractId = contractId;
    return this;			
    
  }
  
  private RCRequireStatus requireInstall;
  
  public RCRequireStatus getRequireInstall() {
    return this.requireInstall;
  }
  
  public RCServiceContractDelegateCriteria setRequireInstall(final RCRequireStatus requireInstall) {
    this.requireInstall = requireInstall;
    return this;			
    
  }
  
  private RCRequireStatus requireRoutineService;
  
  public RCRequireStatus getRequireRoutineService() {
    return this.requireRoutineService;
  }
  
  public RCServiceContractDelegateCriteria setRequireRoutineService(final RCRequireStatus requireRoutineService) {
    this.requireRoutineService = requireRoutineService;
    return this;			
    
  }
  
  private RCEnterprise customer;
  
  public RCEnterprise getCustomer() {
    return this.customer;
  }
  
  public RCServiceContractDelegateCriteria setCustomer(final RCEnterprise customer) {
    this.customer = customer;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCServiceContractDelegateImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProjectInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProjectInfo()) ){
    	hql += " and ((this.projectId  LIKE :projectInfo) or (this.projectName  LIKE :projectInfo))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getContractId()) ){
    	hql += " and (this.contractId  LIKE :contractId)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRequireInstall()) ){
    	hql += " and ((this.installInfo.requireInstall) = (:requireInstall))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRequireRoutineService()) ){
    	hql += " and ((this.routineServiceInfo.requireRoutineService) = (:requireRoutineService))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer()) ){
    	hql += " and ((this.customer) = (:customer))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) && !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo()) ){
    	hql += " and ((((((this.projectName  LIKE :info) or (this.businessMan.name  LIKE :info)) or (this.majorSales.name  LIKE :info)) or (this.customerLink  LIKE :info)) or (this.customerLinkPhone  LIKE :info)) or (this.customerLinkMail  LIKE :info))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.projectId",edu.fudan.mylang.pf.query.OrderItem.DESC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getInfo())){
    	query.setParameter("info",getInfo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getProjectInfo())){
    	query.setParameter("projectInfo",getProjectInfo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getContractId())){
    	query.setParameter("contractId",getContractId()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRequireInstall())){
    	query.setParameter("requireInstall",getRequireInstall()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getRequireRoutineService())){
    	query.setParameter("requireRoutineService",getRequireRoutineService()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getCustomer())){
    	query.setParameter("customer",getCustomer()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCServiceContractDelegateCriteriaImpl() {
    initOrderBys();
  }
}
